<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-99.9.9">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">


<title>Fastmath documentation – Interpolation</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
  width: 0.8em;
  margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ 
  vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
  }
pre.numberSource { margin-left: 3em;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
</style>


<script src="site_libs/quarto-nav/quarto-nav.js"></script>
<script src="site_libs/quarto-nav/headroom.min.js"></script>
<script src="site_libs/clipboard/clipboard.min.js"></script>
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
<script src="site_libs/quarto-search/fuse.min.js"></script>
<script src="site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="./">
<link href="./optimization.html" rel="next">
<link href="./calculus.html" rel="prev">
<link href="./clay/resources/favicon.png" rel="icon" type="image/png">
<script src="site_libs/quarto-html/quarto.js"></script>
<script src="site_libs/quarto-html/popper.min.js"></script>
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
<script src="site_libs/quarto-html/anchor.min.js"></script>
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script id="quarto-search-options" type="application/json">{
  "location": "sidebar",
  "copy-button": false,
  "collapse-after": 3,
  "panel-placement": "start",
  "type": "textbox",
  "limit": 50,
  "keyboard-shortcut": [
    "f",
    "/",
    "s"
  ],
  "show-item-context": false,
  "language": {
    "search-no-results-text": "No results",
    "search-matching-documents-text": "matching documents",
    "search-copy-link-title": "Copy link to search",
    "search-hide-matches-text": "Hide additional matches",
    "search-more-match-text": "more match in this document",
    "search-more-matches-text": "more matches in this document",
    "search-clear-button-title": "Clear",
    "search-text-placeholder": "",
    "search-detached-cancel-button-title": "Cancel",
    "search-submit-button-title": "Submit",
    "search-label": "Search"
  }
}</script>

  <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
  <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>

<script type="text/javascript">
const typesetMath = (el) => {
  if (window.MathJax) {
    // MathJax Typeset
    window.MathJax.typeset([el]);
  } else if (window.katex) {
    // KaTeX Render
    var mathElements = el.getElementsByClassName("math");
    var macros = [];
    for (var i = 0; i < mathElements.length; i++) {
      var texText = mathElements[i].firstChild;
      if (mathElements[i].tagName == "SPAN") {
        window.katex.render(texText.data, mathElements[i], {
          displayMode: mathElements[i].classList.contains('display'),
          throwOnError: false,
          macros: macros,
          fleqn: false
        });
      }
    }
  }
}
window.Quarto = {
  typesetMath
};
</script>

</head>

<body class="nav-sidebar floating">

<div id="quarto-search-results"></div>
  <header id="quarto-header" class="headroom fixed-top">
  <nav class="quarto-secondary-nav">
    <div class="container-fluid d-flex">
      <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
        <i class="bi bi-layout-text-sidebar-reverse"></i>
      </button>
        <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./interpolation.html">Interpolation</a></li></ol></nav>
        <a class="flex-grow-1" role="button" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">      
        </a>
      <button type="button" class="btn quarto-search-button" aria-label="" onclick="window.quartoOpenSearch();">
        <i class="bi bi-search"></i>
      </button>
    </div>
  </nav>
</header>
<!-- content -->
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
<!-- sidebar -->
  <nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
    <div class="pt-lg-2 mt-2 text-left sidebar-header">
    <div class="sidebar-title mb-0 py-0">
      <a href="./">Fastmath documentation</a> 
    </div>
      </div>
        <div class="mt-2 flex-shrink-0 align-items-center">
        <div class="sidebar-search">
        <div id="quarto-search" class="" title="Search"></div>
        </div>
        </div>
    <div class="sidebar-menu-container"> 
    <ul class="list-unstyled mt-1">
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./index.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Preface</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./core.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Core</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./vector_matrix.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Vectors and matrices</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./random.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Random</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./stats.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Statistics</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./polynomials.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Polynomials</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./special.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Special functions</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./calculus.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Calculus</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./interpolation.html" class="sidebar-item-text sidebar-link active">
 <span class="menu-text">Interpolation</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./optimization.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Optimization</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./transform.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Transforms</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./ml.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Machine Learning</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./complex_quaternions.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Complex numbers and quaternions</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./easings.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Easings</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./fields.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Vector fields</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="./efloat.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">EFloat</span></a>
  </div>
</li>
    </ul>
    </div>
</nav>
<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
<!-- margin-sidebar -->
    <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
        <nav id="TOC" role="doc-toc" class="toc-active">
    <h2 id="toc-title">Table of contents</h2>
   
  <ul>
  <li><a href="#d-target" id="toc-d-target" class="nav-link active" data-scroll-target="#d-target">1d target</a></li>
  <li><a href="#d-target-1" id="toc-d-target-1" class="nav-link" data-scroll-target="#d-target-1">2d target</a>
  <ul>
  <li><a href="#grid" id="toc-grid" class="nav-link" data-scroll-target="#grid">Grid</a></li>
  </ul></li>
  <li><a href="#d" id="toc-d" class="nav-link" data-scroll-target="#d">1d</a>
  <ul>
  <li><a href="#linear" id="toc-linear" class="nav-link" data-scroll-target="#linear">Linear</a></li>
  <li><a href="#cubic" id="toc-cubic" class="nav-link" data-scroll-target="#cubic">Cubic</a></li>
  <li><a href="#akima" id="toc-akima" class="nav-link" data-scroll-target="#akima">Akima</a></li>
  <li><a href="#neville" id="toc-neville" class="nav-link" data-scroll-target="#neville">Neville</a></li>
  <li><a href="#barycentric" id="toc-barycentric" class="nav-link" data-scroll-target="#barycentric">Barycentric</a></li>
  <li><a href="#b-spline" id="toc-b-spline" class="nav-link" data-scroll-target="#b-spline">B-spline</a></li>
  <li><a href="#divided-difference" id="toc-divided-difference" class="nav-link" data-scroll-target="#divided-difference">Divided difference</a></li>
  <li><a href="#polynomial" id="toc-polynomial" class="nav-link" data-scroll-target="#polynomial">Polynomial</a></li>
  <li><a href="#monotone" id="toc-monotone" class="nav-link" data-scroll-target="#monotone">Monotone</a></li>
  <li><a href="#step" id="toc-step" class="nav-link" data-scroll-target="#step">Step</a></li>
  <li><a href="#loess" id="toc-loess" class="nav-link" data-scroll-target="#loess">Loess</a></li>
  <li><a href="#cubic-smoothing" id="toc-cubic-smoothing" class="nav-link" data-scroll-target="#cubic-smoothing">Cubic smoothing</a></li>
  </ul></li>
  <li><a href="#d-grid" id="toc-d-grid" class="nav-link" data-scroll-target="#d-grid">2d grid</a>
  <ul>
  <li><a href="#bilinear" id="toc-bilinear" class="nav-link" data-scroll-target="#bilinear">Bilinear</a></li>
  <li><a href="#bicubic" id="toc-bicubic" class="nav-link" data-scroll-target="#bicubic">Bicubic</a></li>
  <li><a href="#cubic-2d" id="toc-cubic-2d" class="nav-link" data-scroll-target="#cubic-2d">Cubic 2d</a></li>
  </ul></li>
  <li><a href="#multivariate-and-kernel-based" id="toc-multivariate-and-kernel-based" class="nav-link" data-scroll-target="#multivariate-and-kernel-based">Multivariate and kernel based</a>
  <ul>
  <li><a href="#microsphere-projection" id="toc-microsphere-projection" class="nav-link" data-scroll-target="#microsphere-projection">Microsphere projection</a></li>
  <li><a href="#shepard" id="toc-shepard" class="nav-link" data-scroll-target="#shepard">Shepard</a></li>
  <li><a href="#radial-basis-function" id="toc-radial-basis-function" class="nav-link" data-scroll-target="#radial-basis-function">Radial Basis Function</a>
  <ul>
  <li><a href="#polynomial-term" id="toc-polynomial-term" class="nav-link" data-scroll-target="#polynomial-term">Polynomial term</a></li>
  <li><a href="#smoothing" id="toc-smoothing" class="nav-link" data-scroll-target="#smoothing">Smoothing</a></li>
  </ul></li>
  <li><a href="#kriging" id="toc-kriging" class="nav-link" data-scroll-target="#kriging">Kriging</a>
  <ul>
  <li><a href="#variograms" id="toc-variograms" class="nav-link" data-scroll-target="#variograms">Variograms</a></li>
  <li><a href="#semi-variograms" id="toc-semi-variograms" class="nav-link" data-scroll-target="#semi-variograms">Semi-variograms</a></li>
  <li><a href="#smoothing-1" id="toc-smoothing-1" class="nav-link" data-scroll-target="#smoothing-1">Smoothing</a></li>
  </ul></li>
  <li><a href="#gaussian-processes" id="toc-gaussian-processes" class="nav-link" data-scroll-target="#gaussian-processes">Gaussian processes</a></li>
  </ul></li>
  </ul>
</nav>
    </div>
<!-- main -->
<main class="content" id="quarto-document-content">

<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Interpolation</h1>
</div>



<div class="quarto-title-meta">

    
  
    
  </div>
  


</header>


<style></style>
<style>.printedClojure .sourceCode {
  background-color: transparent;
  border-style: none;
}
</style>
<style>.clay-limit-image-width .clay-image {max-width: 100%}
.clay-side-by-side .sourceCode {margin: 0}
.clay-side-by-side {margin: 1em 0}
</style>
<script src="interpolation_files/md-default61.js" type="text/javascript"></script>
<script src="interpolation_files/md-default62.js" type="text/javascript"></script>
<p>Interpolation namespace defines the unified API for various interpolation methods. Most of them also extrapolates. Methods include:</p>
<ul>
<li>1d interpolation</li>
<li>2d interpolation on irregular grid points</li>
<li>Multivariate interpolation</li>
<li>Kernel based interpolation</li>
<li>Smoothing</li>
</ul>
<p>All methods are accessible from <code>fastmath.interpolation</code> namespace via a multimethod <code>interpolation</code>. Additionally each method is implemented as a regular function in the dedicated namespace. <code>interpolation</code> returns an interpolant function</p>
<p>Both examples below are equivalent:</p>
<div class="sourceClojure">
<div class="sourceCode" id="cb1"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation <span class="at">:as</span> i]</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>         '[fastmath.interpolation.linear <span class="at">:as</span> linear])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb2"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> i1 </span>(i/interpolation <span class="at">:linear</span> [<span class="dv">1</span> <span class="dv">2</span> <span class="dv">3</span>] [<span class="dv">4</span> <span class="dv">5</span> -<span class="dv">1</span>]))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb3"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> i2 </span>(linear/linear [<span class="dv">1</span> <span class="dv">2</span> <span class="dv">3</span>] [<span class="dv">4</span> <span class="dv">5</span> -<span class="dv">1</span>]))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb4"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>{<span class="at">:i1</span> (i1 <span class="fl">2.5</span>)</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="at">:i2</span> (i2 <span class="fl">2.5</span>)}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb5"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>{<span class="at">:i1</span> <span class="fl">2.0</span>, <span class="at">:i2</span> <span class="fl">2.0</span>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>List of all possible methods:</p>
<div class="sourceClojure">
<div class="sourceCode" id="cb6"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">sort</span> (<span class="kw">keys</span> (<span class="kw">methods</span> i/interpolation)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb7"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>(<span class="at">:akima</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="at">:b-spline</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="at">:barycentric</span></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="at">:bicubic</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="at">:bilinear</span></span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> <span class="at">:cubic</span></span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> <span class="at">:cubic-2d</span></span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> <span class="at">:cubic-smoothing</span></span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> <span class="at">:divided-difference</span></span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a> <span class="at">:gp</span></span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a> <span class="at">:kriging</span></span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a> <span class="at">:linear</span></span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a> <span class="at">:loess</span></span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a> <span class="at">:microsphere-projection</span></span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a> <span class="at">:monotone</span></span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a> <span class="at">:neville</span></span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a> <span class="at">:polynomial</span></span>
<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a> <span class="at">:rbf</span></span>
<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a> <span class="at">:shepard</span></span>
<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a> <span class="at">:step</span></span>
<span id="cb7-21"><a href="#cb7-21" aria-hidden="true" tabindex="-1"></a> <span class="at">:step-after</span></span>
<span id="cb7-22"><a href="#cb7-22" aria-hidden="true" tabindex="-1"></a> <span class="at">:step-before</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>The following functions and samples will be used as a target to illustrate usage of described method.</p>
<section id="d-target" class="level2">
<h2 class="anchored" data-anchor-id="d-target">1d target</h2>
<p><span class="math display">\[f(x)=\sin\left(\frac{x\cos(x+1)}{2}\right)\]</span></p>
<div class="sourceClojure">
<div class="sourceCode" id="cb8"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> target-1d </span>[x] (m/sin (<span class="kw">*</span> <span class="fl">0.5</span> x (m/cos (<span class="kw">inc</span> x)))))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb9"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>(target<span class="dv">-1</span>d <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb10"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.5373775050861961</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Points used in interpolation</p>
<div class="sourceClojure">
<div class="sourceCode" id="cb11"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> xs1 </span>[<span class="fl">0.5</span> <span class="fl">0.69</span> <span class="fl">1.73</span> <span class="fl">2.0</span> <span class="fl">2.28</span> <span class="fl">3.46</span> <span class="fl">3.5</span> <span class="fl">4.18</span> <span class="fl">4.84</span> <span class="fl">5.18</span> <span class="fl">5.53</span> <span class="fl">5.87</span> <span class="fl">6.22</span> <span class="fl">6.5</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb12"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> ys1 </span>(<span class="kw">map</span> target<span class="dv">-1</span>d xs1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/0.png">
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/1.png">
</div>
</section>
<section id="d-target-1" class="level2">
<h2 class="anchored" data-anchor-id="d-target-1">2d target</h2>
<p><span class="math display">\[f(x,y)=\sin\left(\frac{x-100}{10}\cos\left(\frac{y}{20}\right)\right)+\frac{x}{100}+\left(\frac{y-100}{100}\right)^2+1\]</span></p>
<div class="sourceClojure">
<div class="sourceCode" id="cb13"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> target-2d </span>[[x y]] (m/+ <span class="fl">1.0</span> (m/sin (<span class="kw">*</span> (<span class="kw">/</span> (<span class="kw">-</span> x <span class="fl">100.0</span>) <span class="fl">10.0</span>) (m/cos (<span class="kw">/</span> y <span class="fl">20.0</span>))))</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>                          (m// x <span class="fl">100.0</span>)</span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>                          (m/sq (m// (m/- y <span class="fl">100.0</span>) <span class="fl">100.0</span>))))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb14"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>(target<span class="dv">-2</span>d [<span class="dv">20</span> <span class="dv">20</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb15"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="fl">2.7649202623006808</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<section id="grid" class="level3">
<h3 class="anchored" data-anchor-id="grid">Grid</h3>
<p>Points for grid interpolation</p>
<div class="sourceClojure">
<div class="sourceCode" id="cb16"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> xs2 </span>[<span class="dv">20</span> <span class="dv">25</span> <span class="dv">30</span> <span class="dv">35</span> <span class="dv">40</span> <span class="dv">50</span> <span class="dv">58</span> <span class="dv">66</span> <span class="dv">100</span> <span class="dv">121</span> <span class="dv">140</span> <span class="dv">150</span> <span class="dv">160</span> <span class="dv">170</span> <span class="dv">180</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb17"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> ys2 </span>[<span class="dv">20</span> <span class="dv">30</span> <span class="dv">58</span> <span class="dv">66</span> <span class="dv">90</span>  <span class="dv">121</span> <span class="dv">140</span> <span class="dv">152</span> <span class="dv">170</span>     <span class="dv">180</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb18"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> zss </span>(<span class="kw">for</span> [x xs2]</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>         (<span class="kw">for</span> [y ys2]</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a>           (target<span class="dv">-2</span>d [x y]))))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb19"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> xss </span>(<span class="kw">repeatedly</span> <span class="dv">300</span> #(<span class="kw">vector</span> (r/drandom uniform-seed<span class="dv">-44</span> <span class="dv">20</span> <span class="dv">180</span>)</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a>                                (r/drandom uniform-seed<span class="dv">-44</span> <span class="dv">20</span> <span class="dv">180</span>))))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb20"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> ys3 </span>(<span class="kw">map</span> target<span class="dv">-2</span>d xss))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb21"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> error-1d</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a>  [interpolant]</span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a>  (m/sqrt (calc/integrate (<span class="kw">fn</span> [^<span class="kw">double</span> x] (m/sq (m/- (target<span class="dv">-1</span>d x) (interpolant x)))) <span class="fl">0.5</span> <span class="fl">6.5</span>)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb22"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d (linear/linear xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb23"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.2110302144467739</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>For 2d case the following formula will be used:</p>
<p><span class="math display">\[error_{2d}(f,g)=\|f-g\|=\sqrt{\int_{20}^{180}\int_{20}^{180}|f(x,y)-g(x,y)|^2\,dx dy}\]</span></p>
<div class="sourceClojure">
<div class="sourceCode" id="cb24"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> error-2d</span></span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a>  [interpolant]</span>
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a>  (m/sqrt (calc/cubature (<span class="kw">fn</span> [xy] (m/sq (m/- (target<span class="dv">-2</span>d xy) (interpolant xy))))</span>
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a>                         [<span class="fl">20.0</span> <span class="fl">20.0</span>]</span>
<span id="cb24-5"><a href="#cb24-5" aria-hidden="true" tabindex="-1"></a>                         [<span class="fl">180.0</span> <span class="fl">180.0</span>])))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb25"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d (linear/bilinear xs2 ys2 zss))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb26"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="fl">102.03678750452109</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
</section>
<section id="d" class="level2">
<h2 class="anchored" data-anchor-id="d">1d</h2>
<section id="linear" class="level3">
<h3 class="anchored" data-anchor-id="linear">Linear</h3>
<p>Linear piecewise interpolation and extrapolation. Extrapolation uses a slope from the boundaries. See more on <a href="https://en.wikipedia.org/wiki/Linear_interpolation">Wikipedia</a></p>
<div class="sourceClojure">
<div class="sourceCode" id="cb27"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.linear <span class="at">:as</span> linear])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb28"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> linear </span>(linear/linear xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb29"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a>(linear <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb30"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.49924424111385607</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb31"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d linear)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb32"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.2110302144467739</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/2.png">
</div>
</section>
<section id="cubic" class="level3">
<h3 class="anchored" data-anchor-id="cubic">Cubic</h3>
<p>Natural cubic spline (second derivatives at boundary points have value <span class="math inline">\(0\)</span>) interpolation and extrapolation. See more on <a href="https://en.wikipedia.org/wiki/Spline_interpolation">Wikipedia</a></p>
<div class="sourceClojure">
<div class="sourceCode" id="cb33"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.cubic <span class="at">:as</span> cubic])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb34"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> cubic </span>(cubic/cubic xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb35"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a>(cubic <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb36"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.5516054931803801</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb37"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d cubic)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb38"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb38-1"><a href="#cb38-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.0275840592896124</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/3.png">
</div>
</section>
<section id="akima" class="level3">
<h3 class="anchored" data-anchor-id="akima">Akima</h3>
<p>See more on <a href="https://en.wikipedia.org/wiki/Akima_spline">Wikipedia</a></p>
<div class="sourceClojure">
<div class="sourceCode" id="cb39"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.acm <span class="at">:as</span> acm])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb40"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> akima </span>(acm/akima xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb41"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a>(akima <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb42"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb42-1"><a href="#cb42-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.5335842087231077</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb43"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d akima)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb44"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.03487751999898592</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/4.png">
</div>
</section>
<section id="neville" class="level3">
<h3 class="anchored" data-anchor-id="neville">Neville</h3>
<p>See more on <a href="https://en.wikipedia.org/wiki/Neville%27s_algorithm">Wikipedia</a></p>
<div class="sourceClojure">
<div class="sourceCode" id="cb45"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb45-1"><a href="#cb45-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.acm <span class="at">:as</span> acm])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb46"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> neville </span>(acm/neville xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb47"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb47-1"><a href="#cb47-1" aria-hidden="true" tabindex="-1"></a>(neville <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb48"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb48-1"><a href="#cb48-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.5432043004304535</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb49"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb49-1"><a href="#cb49-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d neville)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb50"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.8675392877418397</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/5.png">
</div>
</section>
<section id="barycentric" class="level3">
<h3 class="anchored" data-anchor-id="barycentric">Barycentric</h3>
<p>Rational interpolation as described in <a href="https://numerical.recipes/book.html">Numerical Recipes ch.&nbsp;3.4</a>. The <code>order</code> (default <span class="math inline">\(1\)</span>) parameter contols number of points used to calculate weights. Higher order means better accuracy.</p>
<div class="sourceClojure">
<div class="sourceCode" id="cb51"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb51-1"><a href="#cb51-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.barycentric <span class="at">:as</span> barycentric])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb52"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb52-1"><a href="#cb52-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> barycentric</span></span>
<span id="cb52-2"><a href="#cb52-2" aria-hidden="true" tabindex="-1"></a>  ([] (barycentric/barycentric xs1 ys1))</span>
<span id="cb52-3"><a href="#cb52-3" aria-hidden="true" tabindex="-1"></a>  ([order] (barycentric/barycentric xs1 ys1 {<span class="at">:order</span> order})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb53"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb53-1"><a href="#cb53-1" aria-hidden="true" tabindex="-1"></a>((barycentric) <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb54"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb54-1"><a href="#cb54-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.5492673111356233</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th">order</th>
<th data-quarto-table-cell-role="th">error</th>
<th data-quarto-table-cell-role="th">barrycentric(4.0)</th>
<th data-quarto-table-cell-role="th">error at 4.0</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>0</td>
<td>0.5193270391333753</td>
<td>0.6329368698778738</td>
<td>0.0955593647916777</td>
</tr>
<tr class="even">
<td>1</td>
<td>0.03176373180495161</td>
<td>0.5492673111356233</td>
<td>0.011889806049427243</td>
</tr>
<tr class="odd">
<td>2</td>
<td>0.05019164899125852</td>
<td>0.5160607443493412</td>
<td>0.021316760736854845</td>
</tr>
<tr class="even">
<td>3</td>
<td>0.028650229888319802</td>
<td>0.5232915410624766</td>
<td>0.014085964023719533</td>
</tr>
<tr class="odd">
<td>4</td>
<td>0.00351102181650211</td>
<td>0.5349629695697342</td>
<td>0.0024145355164618687</td>
</tr>
<tr class="even">
<td>5</td>
<td>0.009022181871044352</td>
<td>0.5387189359388596</td>
<td>0.0013414308526634722</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/6.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/7.png" class="clay-image img-fluid"></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/8.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/9.png" class="clay-image img-fluid"></td>
</tr>
<tr class="odd">
<td><img src="interpolation_files/10.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/11.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<section id="b-spline" class="level3">
<h3 class="anchored" data-anchor-id="b-spline">B-spline</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb55"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb55-1"><a href="#cb55-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.ssj <span class="at">:as</span> ssj])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb56"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb56-1"><a href="#cb56-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> b-spline</span></span>
<span id="cb56-2"><a href="#cb56-2" aria-hidden="true" tabindex="-1"></a>  ([] (ssj/b-spline xs1 ys1))</span>
<span id="cb56-3"><a href="#cb56-3" aria-hidden="true" tabindex="-1"></a>  ([degree] (b-spline degree <span class="va">nil</span>))</span>
<span id="cb56-4"><a href="#cb56-4" aria-hidden="true" tabindex="-1"></a>  ([degree hp1] (ssj/b-spline xs1 ys1 {<span class="at">:degree</span> degree <span class="at">:hp1</span> hp1})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb57"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb57-1"><a href="#cb57-1" aria-hidden="true" tabindex="-1"></a>((b-spline) <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb58"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb58-1"><a href="#cb58-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.1610170071559863</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/12.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/13.png" class="clay-image img-fluid"></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/14.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/15.png" class="clay-image img-fluid"></td>
</tr>
<tr class="odd">
<td><img src="interpolation_files/16.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/17.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<section id="divided-difference" class="level3">
<h3 class="anchored" data-anchor-id="divided-difference">Divided difference</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb59"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb59-1"><a href="#cb59-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.acm <span class="at">:as</span> acm])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb60"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb60-1"><a href="#cb60-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> divided-difference </span>(acm/divided-difference xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb61"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb61-1"><a href="#cb61-1" aria-hidden="true" tabindex="-1"></a>(divided-difference <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb62"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb62-1"><a href="#cb62-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.5432043004304531</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb63"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb63-1"><a href="#cb63-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d divided-difference)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb64"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb64-1"><a href="#cb64-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.8675392877418397</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/18.png">
</div>
</section>
<section id="polynomial" class="level3">
<h3 class="anchored" data-anchor-id="polynomial">Polynomial</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb65"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb65-1"><a href="#cb65-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.ssj <span class="at">:as</span> ssj])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb66"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb66-1"><a href="#cb66-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> polynomial </span>(ssj/polynomial xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb67"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb67-1"><a href="#cb67-1" aria-hidden="true" tabindex="-1"></a>(polynomial <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb68"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb68-1"><a href="#cb68-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.5432043380309324</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb69"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb69-1"><a href="#cb69-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d polynomial)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb70"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb70-1"><a href="#cb70-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.8675392846805364</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/19.png">
</div>
</section>
<section id="monotone" class="level3">
<h3 class="anchored" data-anchor-id="monotone">Monotone</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb71"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb71-1"><a href="#cb71-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.monotone <span class="at">:as</span> monotone])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb72"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb72-1"><a href="#cb72-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> monotone </span>(monotone/monotone xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb73"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb73-1"><a href="#cb73-1" aria-hidden="true" tabindex="-1"></a>(monotone <span class="fl">4.0</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb74"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb74-1"><a href="#cb74-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.6588206176299103</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb75"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb75-1"><a href="#cb75-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d monotone)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb76"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb76-1"><a href="#cb76-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.1517488499630331</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/20.png">
</div>
</section>
<section id="step" class="level3">
<h3 class="anchored" data-anchor-id="step">Step</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb77"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb77-1"><a href="#cb77-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.step <span class="at">:as</span> step])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb78"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb78-1"><a href="#cb78-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> step</span></span>
<span id="cb78-2"><a href="#cb78-2" aria-hidden="true" tabindex="-1"></a>  ([] (step/step xs1 ys1))</span>
<span id="cb78-3"><a href="#cb78-3" aria-hidden="true" tabindex="-1"></a>  ([point] (step/step xs1 ys1 {<span class="at">:point</span> point})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb79"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb79-1"><a href="#cb79-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> step-before </span>(step/step-before xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb80"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb80-1"><a href="#cb80-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> step-after </span>(step/step-after xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th">method</th>
<th data-quarto-table-cell-role="th">error</th>
<th data-quarto-table-cell-role="th">value at 4.0</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>step-before</td>
<td>0.849159325039357</td>
<td>0.8087819747808206</td>
</tr>
<tr class="even">
<td>step-after</td>
<td>0.7429959099336633</td>
<td>-0.3605827968499356</td>
</tr>
<tr class="odd">
<td>step</td>
<td>0.4328611328633974</td>
<td>0.8087819747808206</td>
</tr>
<tr class="even">
<td>step (point=0.55)</td>
<td>0.42287483285733546</td>
<td>0.8087819747808206</td>
</tr>
<tr class="odd">
<td>step (point=0.25)</td>
<td>0.5962341092433667</td>
<td>0.8087819747808206</td>
</tr>
<tr class="even">
<td>step (point=0.75)</td>
<td>0.49446591280052093</td>
<td>-0.3605827968499356</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/21.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/22.png" class="clay-image img-fluid"></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/23.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/24.png" class="clay-image img-fluid"></td>
</tr>
<tr class="odd">
<td><img src="interpolation_files/25.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/26.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<section id="loess" class="level3">
<h3 class="anchored" data-anchor-id="loess">Loess</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb81"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb81-1"><a href="#cb81-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.acm <span class="at">:as</span> acm])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb82"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb82-1"><a href="#cb82-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> loess</span></span>
<span id="cb82-2"><a href="#cb82-2" aria-hidden="true" tabindex="-1"></a>  ([] (acm/loess xs1 ys1))</span>
<span id="cb82-3"><a href="#cb82-3" aria-hidden="true" tabindex="-1"></a>  ([bandwidth] (acm/loess xs1 ys1 {<span class="at">:bandwidth</span> bandwidth})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/27.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/28.png" class="clay-image img-fluid"></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/29.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/30.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<section id="cubic-smoothing" class="level3">
<h3 class="anchored" data-anchor-id="cubic-smoothing">Cubic smoothing</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb83"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb83-1"><a href="#cb83-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.ssj <span class="at">:as</span> ssj])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb84"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb84-1"><a href="#cb84-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> cubic-smoothing</span></span>
<span id="cb84-2"><a href="#cb84-2" aria-hidden="true" tabindex="-1"></a>  ([] (ssj/cubic-smoothing xs1 ys1))</span>
<span id="cb84-3"><a href="#cb84-3" aria-hidden="true" tabindex="-1"></a>  ([rho] (ssj/cubic-smoothing xs1 ys1 {<span class="at">:rho</span> rho})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/31.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/32.png" class="clay-image img-fluid"></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/33.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/34.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
</section>
<section id="d-grid" class="level2">
<h2 class="anchored" data-anchor-id="d-grid">2d grid</h2>
<section id="bilinear" class="level3">
<h3 class="anchored" data-anchor-id="bilinear">Bilinear</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb85"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb85-1"><a href="#cb85-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.linear <span class="at">:as</span> linear])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb86"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb86-1"><a href="#cb86-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> bilinear </span>(linear/bilinear xs2 ys2 zss))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb87"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb87-1"><a href="#cb87-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d bilinear)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb88"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb88-1"><a href="#cb88-1" aria-hidden="true" tabindex="-1"></a><span class="fl">102.03678750452109</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="bicubic" class="level3">
<h3 class="anchored" data-anchor-id="bicubic">Bicubic</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb89"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb89-1"><a href="#cb89-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.acm <span class="at">:as</span> acm])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb90"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb90-1"><a href="#cb90-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> bicubic </span>(acm/bicubic xs2 ys2 zss))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb91"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb91-1"><a href="#cb91-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d bicubic)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb92"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb92-1"><a href="#cb92-1" aria-hidden="true" tabindex="-1"></a><span class="fl">103.97025992767536</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="cubic-2d" class="level3">
<h3 class="anchored" data-anchor-id="cubic-2d">Cubic 2d</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb93"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb93-1"><a href="#cb93-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.cubic <span class="at">:as</span> cubic])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb94"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb94-1"><a href="#cb94-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> cubic-2d </span>(cubic/cubic<span class="dv">-2</span>d xs2 ys2 zss))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb95"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb95-1"><a href="#cb95-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d cubic<span class="dv">-2</span>d)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb96"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb96-1"><a href="#cb96-1" aria-hidden="true" tabindex="-1"></a><span class="fl">103.23387133898065</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
</section>
<section id="multivariate-and-kernel-based" class="level2">
<h2 class="anchored" data-anchor-id="multivariate-and-kernel-based">Multivariate and kernel based</h2>
<section id="microsphere-projection" class="level3">
<h3 class="anchored" data-anchor-id="microsphere-projection">Microsphere projection</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb97"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb97-1"><a href="#cb97-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.acm <span class="at">:as</span> acm])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<tbody>
<tr class="odd">
<td><img src="interpolation_files/35.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb98"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb98-1"><a href="#cb98-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-1</span>d (acm/microsphere-projection xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb99"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb99-1"><a href="#cb99-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.20201293127226447</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb100"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb100-1"><a href="#cb100-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d (acm/microsphere-projection xss ys3))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb101"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb101-1"><a href="#cb101-1" aria-hidden="true" tabindex="-1"></a><span class="fl">52.997540168155005</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="shepard" class="level3">
<h3 class="anchored" data-anchor-id="shepard">Shepard</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb102"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb102-1"><a href="#cb102-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.shepard <span class="at">:as</span> shepard])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/36.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/37.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<section id="radial-basis-function" class="level3">
<h3 class="anchored" data-anchor-id="radial-basis-function">Radial Basis Function</h3>
<div class="sourceClojure">
<div class="sourceCode" id="cb103"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb103-1"><a href="#cb103-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.interpolation.rbf <span class="at">:as</span> rbf])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb104"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb104-1"><a href="#cb104-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> chart-f </span>[f title] (<span class="kw">-&gt;</span> (ggplot/function f {<span class="at">:x</span> [-<span class="dv">5</span> <span class="dv">5</span>] <span class="at">:title</span> title})</span>
<span id="cb104-2"><a href="#cb104-2" aria-hidden="true" tabindex="-1"></a>                         (ggplot/-&gt;image)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/38.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/39.png" class="clay-image img-fluid"></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/40.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/41.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/42.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/43.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
<tr class="odd">
<td><img src="interpolation_files/44.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/45.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<section id="polynomial-term" class="level4">
<h4 class="anchored" data-anchor-id="polynomial-term">Polynomial term</h4>
<div class="sourceClojure">
<div class="sourceCode" id="cb105"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb105-1"><a href="#cb105-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> polynomial-terms-1d </span>[^<span class="kw">double</span> x]</span>
<span id="cb105-2"><a href="#cb105-2" aria-hidden="true" tabindex="-1"></a>  [<span class="fl">1.0</span> x (m/sq x)])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb106"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb106-1"><a href="#cb106-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> polynomial-terms-2d </span>[[^<span class="kw">double</span> x ^<span class="kw">double</span> y]]</span>
<span id="cb106-2"><a href="#cb106-2" aria-hidden="true" tabindex="-1"></a>  [<span class="fl">1.0</span> x y (m/* x y) (m/sq x) (m/sq y)])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<thead>
<tr class="header">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th"></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="interpolation_files/46.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/47.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
<tr class="odd">
<td><img src="interpolation_files/48.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/49.png" class="clay-image img-fluid"></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb107"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb107-1"><a href="#cb107-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d (rbf/rbf xss ys3 (kernel/rbf <span class="at">:gaussian</span> {<span class="at">:shape</span> <span class="fl">0.1</span>})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb108"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb108-1"><a href="#cb108-1" aria-hidden="true" tabindex="-1"></a><span class="fl">365.96788014805696</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb109"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb109-1"><a href="#cb109-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d (rbf/rbf xss ys3 (kernel/rbf <span class="at">:matern-c2</span> {<span class="at">:shape</span> <span class="fl">0.15</span>})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb110"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb110-1"><a href="#cb110-1" aria-hidden="true" tabindex="-1"></a><span class="fl">316.10296877225454</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb111"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb111-1"><a href="#cb111-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d (rbf/rbf xss ys3 (kernel/rbf <span class="at">:gaussians-laguerre-22</span> {<span class="at">:shape</span> <span class="fl">0.07</span>})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb112"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb112-1"><a href="#cb112-1" aria-hidden="true" tabindex="-1"></a><span class="fl">376.435234072405</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb113"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb113-1"><a href="#cb113-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d (rbf/rbf xss ys3 (kernel/rbf <span class="at">:thin-plate</span>)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb114"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb114-1"><a href="#cb114-1" aria-hidden="true" tabindex="-1"></a><span class="fl">49.070725801843054</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="smoothing" class="level4">
<h4 class="anchored" data-anchor-id="smoothing">Smoothing</h4>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<tbody>
<tr class="odd">
<td><img src="interpolation_files/50.png" class="clay-image img-fluid"></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/51.png" class="clay-image img-fluid"></td>
</tr>
<tr class="odd">
<td><img src="interpolation_files/52.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
</section>
<section id="kriging" class="level3">
<h3 class="anchored" data-anchor-id="kriging">Kriging</h3>
<section id="variograms" class="level4">
<h4 class="anchored" data-anchor-id="variograms">Variograms</h4>
<div class="sourceClojure">
<div class="sourceCode" id="cb115"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb115-1"><a href="#cb115-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">require</span> '[fastmath.kernel.variogram <span class="at">:as</span> variogram]</span>
<span id="cb115-2"><a href="#cb115-2" aria-hidden="true" tabindex="-1"></a>         '[fastmath.interpolation.kriging <span class="at">:as</span> kriging])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb116"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb116-1"><a href="#cb116-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">defn</span><span class="fu"> svar-image </span>[f emp title]</span>
<span id="cb116-2"><a href="#cb116-2" aria-hidden="true" tabindex="-1"></a>  (<span class="kw">let</span> [x (<span class="kw">map</span> <span class="at">:h</span> emp)</span>
<span id="cb116-3"><a href="#cb116-3" aria-hidden="true" tabindex="-1"></a>        y (<span class="kw">map</span> <span class="at">:gamma</span> emp)]</span>
<span id="cb116-4"><a href="#cb116-4" aria-hidden="true" tabindex="-1"></a>    (<span class="kw">-&gt;</span> (ggplot/function+scatter f x y {<span class="at">:title</span> title <span class="at">:ylim</span> [<span class="dv">0</span> <span class="va">nil</span>]})</span>
<span id="cb116-5"><a href="#cb116-5" aria-hidden="true" tabindex="-1"></a>        (ggplot/-&gt;image))))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb117"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb117-1"><a href="#cb117-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> empirical-matheron-1d </span>(variogram/empirical xs1 ys1))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb118"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb118-1"><a href="#cb118-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> empirical-matheron </span>(variogram/empirical xss ys3 {<span class="at">:size</span> <span class="dv">20</span>}))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb119"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb119-1"><a href="#cb119-1" aria-hidden="true" tabindex="-1"></a>empirical-matheron</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb120"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb120-1"><a href="#cb120-1" aria-hidden="true" tabindex="-1"></a>[{<span class="at">:n</span> <span class="dv">116</span>, <span class="at">:h</span> <span class="fl">3.3604788552002978</span>, <span class="at">:gamma</span> <span class="fl">0.05610650116225876</span>}</span>
<span id="cb120-2"><a href="#cb120-2" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">385</span>, <span class="at">:h</span> <span class="fl">7.841219583707931</span>, <span class="at">:gamma</span> <span class="fl">0.18995728933979483</span>}</span>
<span id="cb120-3"><a href="#cb120-3" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">606</span>, <span class="at">:h</span> <span class="fl">12.72578480586009</span>, <span class="at">:gamma</span> <span class="fl">0.399844655716175</span>}</span>
<span id="cb120-4"><a href="#cb120-4" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">856</span>, <span class="at">:h</span> <span class="fl">17.611233442491304</span>, <span class="at">:gamma</span> <span class="fl">0.4194793467635297</span>}</span>
<span id="cb120-5"><a href="#cb120-5" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1019</span>, <span class="at">:h</span> <span class="fl">22.694649851980536</span>, <span class="at">:gamma</span> <span class="fl">0.4993167205111838</span>}</span>
<span id="cb120-6"><a href="#cb120-6" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1173</span>, <span class="at">:h</span> <span class="fl">27.74503808347392</span>, <span class="at">:gamma</span> <span class="fl">0.5232922610403302</span>}</span>
<span id="cb120-7"><a href="#cb120-7" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1322</span>, <span class="at">:h</span> <span class="fl">32.696030602647625</span>, <span class="at">:gamma</span> <span class="fl">0.5223125852571721</span>}</span>
<span id="cb120-8"><a href="#cb120-8" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1527</span>, <span class="at">:h</span> <span class="fl">37.65818295299809</span>, <span class="at">:gamma</span> <span class="fl">0.5426056881417575</span>}</span>
<span id="cb120-9"><a href="#cb120-9" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1594</span>, <span class="at">:h</span> <span class="fl">42.65227807229347</span>, <span class="at">:gamma</span> <span class="fl">0.5227361157844413</span>}</span>
<span id="cb120-10"><a href="#cb120-10" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1803</span>, <span class="at">:h</span> <span class="fl">47.67443166086058</span>, <span class="at">:gamma</span> <span class="fl">0.5243286183079909</span>}</span>
<span id="cb120-11"><a href="#cb120-11" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1784</span>, <span class="at">:h</span> <span class="fl">52.675449304556054</span>, <span class="at">:gamma</span> <span class="fl">0.5272068497879318</span>}</span>
<span id="cb120-12"><a href="#cb120-12" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1922</span>, <span class="at">:h</span> <span class="fl">57.731016242599935</span>, <span class="at">:gamma</span> <span class="fl">0.5285755419763869</span>}</span>
<span id="cb120-13"><a href="#cb120-13" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1909</span>, <span class="at">:h</span> <span class="fl">62.70585327047225</span>, <span class="at">:gamma</span> <span class="fl">0.5652895296636227</span>}</span>
<span id="cb120-14"><a href="#cb120-14" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1966</span>, <span class="at">:h</span> <span class="fl">67.77992830214916</span>, <span class="at">:gamma</span> <span class="fl">0.5265816327093601</span>}</span>
<span id="cb120-15"><a href="#cb120-15" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1977</span>, <span class="at">:h</span> <span class="fl">72.71580210020514</span>, <span class="at">:gamma</span> <span class="fl">0.49759061919470493</span>}]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/53.png">
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb121"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb121-1"><a href="#cb121-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> empirical-cressie </span>(variogram/empirical xss ys3 {<span class="at">:estimator</span> <span class="at">:cressie</span> <span class="at">:size</span> <span class="dv">20</span>}))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/54.png">
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb122"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb122-1"><a href="#cb122-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> empirical-highly-robust </span>(variogram/empirical xss ys3 {<span class="at">:estimator</span> <span class="at">:highly-robust</span> <span class="at">:size</span> <span class="dv">20</span></span>
<span id="cb122-2"><a href="#cb122-2" aria-hidden="true" tabindex="-1"></a>                                                         <span class="at">:remove-outliers</span>? <span class="va">true</span>}))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb123"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb123-1"><a href="#cb123-1" aria-hidden="true" tabindex="-1"></a>empirical-highly-robust</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb124"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb124-1"><a href="#cb124-1" aria-hidden="true" tabindex="-1"></a>[{<span class="at">:n</span> <span class="dv">116</span>, <span class="at">:h</span> <span class="fl">3.3604788552002978</span>, <span class="at">:gamma</span> <span class="fl">0.02913016400873318</span>}</span>
<span id="cb124-2"><a href="#cb124-2" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">385</span>, <span class="at">:h</span> <span class="fl">7.841219583707931</span>, <span class="at">:gamma</span> <span class="fl">0.14056514492191244</span>}</span>
<span id="cb124-3"><a href="#cb124-3" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">606</span>, <span class="at">:h</span> <span class="fl">12.72578480586009</span>, <span class="at">:gamma</span> <span class="fl">0.42633847448010354</span>}</span>
<span id="cb124-4"><a href="#cb124-4" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">856</span>, <span class="at">:h</span> <span class="fl">17.611233442491304</span>, <span class="at">:gamma</span> <span class="fl">0.44483727296978925</span>}</span>
<span id="cb124-5"><a href="#cb124-5" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1019</span>, <span class="at">:h</span> <span class="fl">22.694649851980536</span>, <span class="at">:gamma</span> <span class="fl">0.5434941912574424</span>}</span>
<span id="cb124-6"><a href="#cb124-6" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1173</span>, <span class="at">:h</span> <span class="fl">27.74503808347392</span>, <span class="at">:gamma</span> <span class="fl">0.571757191071463</span>}</span>
<span id="cb124-7"><a href="#cb124-7" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1322</span>, <span class="at">:h</span> <span class="fl">32.696030602647625</span>, <span class="at">:gamma</span> <span class="fl">0.5504904163482222</span>}</span>
<span id="cb124-8"><a href="#cb124-8" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1527</span>, <span class="at">:h</span> <span class="fl">37.65818295299809</span>, <span class="at">:gamma</span> <span class="fl">0.5905951431086924</span>}</span>
<span id="cb124-9"><a href="#cb124-9" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1594</span>, <span class="at">:h</span> <span class="fl">42.65227807229347</span>, <span class="at">:gamma</span> <span class="fl">0.5577607587471852</span>}</span>
<span id="cb124-10"><a href="#cb124-10" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1803</span>, <span class="at">:h</span> <span class="fl">47.67443166086058</span>, <span class="at">:gamma</span> <span class="fl">0.555261258787647</span>}</span>
<span id="cb124-11"><a href="#cb124-11" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1784</span>, <span class="at">:h</span> <span class="fl">52.675449304556054</span>, <span class="at">:gamma</span> <span class="fl">0.561444986664588</span>}</span>
<span id="cb124-12"><a href="#cb124-12" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1922</span>, <span class="at">:h</span> <span class="fl">57.731016242599935</span>, <span class="at">:gamma</span> <span class="fl">0.5631892305752904</span>}</span>
<span id="cb124-13"><a href="#cb124-13" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1909</span>, <span class="at">:h</span> <span class="fl">62.70585327047225</span>, <span class="at">:gamma</span> <span class="fl">0.6128688264262536</span>}</span>
<span id="cb124-14"><a href="#cb124-14" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1966</span>, <span class="at">:h</span> <span class="fl">67.77992830214916</span>, <span class="at">:gamma</span> <span class="fl">0.5591266023267967</span>}</span>
<span id="cb124-15"><a href="#cb124-15" aria-hidden="true" tabindex="-1"></a> {<span class="at">:n</span> <span class="dv">1977</span>, <span class="at">:h</span> <span class="fl">72.71580210020514</span>, <span class="at">:gamma</span> <span class="fl">0.5142798048326319</span>}]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb125"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb125-1"><a href="#cb125-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> empirical-quantile </span>(variogram/empirical xss ys3 {<span class="at">:estimator</span> <span class="at">:quantile</span> <span class="at">:size</span> <span class="dv">50</span></span>
<span id="cb125-2"><a href="#cb125-2" aria-hidden="true" tabindex="-1"></a>                                                    <span class="at">:quantile</span> <span class="fl">0.92</span>}))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb126"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb126-1"><a href="#cb126-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> empirical-M-robust </span>(variogram/empirical xss ys3 {<span class="at">:estimator</span> <span class="at">:m-robust</span> <span class="at">:size</span> <span class="dv">50</span>}))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/55.png">
</div>
</section>
<section id="semi-variograms" class="level4">
<h4 class="anchored" data-anchor-id="semi-variograms">Semi-variograms</h4>
<div class="sourceClojure">
<div class="sourceCode" id="cb127"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb127-1"><a href="#cb127-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> variogram-linear  </span>(variogram/fit empirical-quantile <span class="at">:linear</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb128"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb128-1"><a href="#cb128-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> variogram-gaussian </span>(variogram/fit empirical-highly-robust <span class="at">:gaussian</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb129"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb129-1"><a href="#cb129-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> variogram-pentaspherical </span>(variogram/fit empirical-highly-robust <span class="at">:pentaspherical</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb130"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb130-1"><a href="#cb130-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> variogram-rbf-wendland-2-3 </span>(variogram/fit empirical-highly-robust (kernel/rbf <span class="at">:wendland</span> {<span class="at">:s</span> <span class="dv">2</span> <span class="at">:k</span> <span class="dv">3</span>})))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb131"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb131-1"><a href="#cb131-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> variogram-superspherical-1d </span>(variogram/fit empirical-matheron<span class="dv">-1</span>d <span class="at">:tplstable</span> {<span class="at">:order</span> <span class="fl">1.9</span> <span class="at">:defaults</span> {<span class="at">:beta</span> <span class="fl">14.0</span>}}))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb132"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb132-1"><a href="#cb132-1" aria-hidden="true" tabindex="-1"></a>(((variogram/-&gt;superspherical <span class="fl">1.0</span>) {<span class="at">:nugget</span> <span class="fl">0.1</span> <span class="at">:psill</span> <span class="fl">0.5</span> <span class="at">:range</span> <span class="fl">1.0</span>}) <span class="fl">0.4</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb133"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb133-1"><a href="#cb133-1" aria-hidden="true" tabindex="-1"></a><span class="fl">0.384</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="clay-image">
<img class="clay-image" src="interpolation_files/56.png">
</div>
<div class="clay-table">
<div>
<div class="table-responsive">
<table class="table table-hover clay-table" data-quarto-postprocess="true">
<tbody>
<tr class="odd">
<td><img src="interpolation_files/57.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/58.png" class="clay-image img-fluid"></td>
</tr>
<tr class="even">
<td><img src="interpolation_files/59.png" class="clay-image img-fluid"></td>
<td><img src="interpolation_files/60.png" class="clay-image img-fluid"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb134"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb134-1"><a href="#cb134-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> kriging-linear </span>(kriging/kriging xss ys3 variogram-linear))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb135"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb135-1"><a href="#cb135-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> kriging-gaussian </span>(kriging/kriging xss ys3 variogram-gaussian))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb136"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb136-1"><a href="#cb136-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> kriging-pentaspherical </span>(kriging/kriging xss ys3 variogram-pentaspherical))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb137"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb137-1"><a href="#cb137-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> kriging-rbf-wendland-2-3 </span>(kriging/kriging xss ys3 variogram-rbf-wendland<span class="dv">-2-3</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb138"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb138-1"><a href="#cb138-1" aria-hidden="true" tabindex="-1"></a>(error<span class="dv">-2</span>d kriging-linear)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="printedClojure">
<div class="sourceCode" id="cb139"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb139-1"><a href="#cb139-1" aria-hidden="true" tabindex="-1"></a><span class="fl">56.63607635102724</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="sourceClojure">
<div class="sourceCode" id="cb140"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb140-1"><a href="#cb140-1" aria-hidden="true" tabindex="-1"></a>(<span class="bu">def</span><span class="fu"> vl </span>(variogram/linear {<span class="at">:nugget</span> <span class="fl">0.03</span> <span class="at">:sill</span> <span class="fl">0.5</span> <span class="at">:range</span> <span class="fl">14.0</span>}))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="smoothing-1" class="level4">
<h4 class="anchored" data-anchor-id="smoothing-1">Smoothing</h4>
</section>
</section>
<section id="gaussian-processes" class="level3">
<h3 class="anchored" data-anchor-id="gaussian-processes">Gaussian processes</h3>
<div style="background-color:grey;height:2px;width:100%;"></div>
<div><pre><small><small>source: <a href="https://github.com/generateme/fastmath//blob/master/clay/interpolation.clj">clay/interpolation.clj</a></small></small></pre></div>


</section>
</section>

</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
  const toggleBodyColorMode = (bsSheetEl) => {
    const mode = bsSheetEl.getAttribute("data-mode");
    const bodyEl = window.document.querySelector("body");
    if (mode === "dark") {
      bodyEl.classList.add("quarto-dark");
      bodyEl.classList.remove("quarto-light");
    } else {
      bodyEl.classList.add("quarto-light");
      bodyEl.classList.remove("quarto-dark");
    }
  }
  const toggleBodyColorPrimary = () => {
    const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
    if (bsSheetEl) {
      toggleBodyColorMode(bsSheetEl);
    }
  }
  toggleBodyColorPrimary();  
  const icon = "";
  const anchorJS = new window.AnchorJS();
  anchorJS.options = {
    placement: 'right',
    icon: icon
  };
  anchorJS.add('.anchored');
  const isCodeAnnotation = (el) => {
    for (const clz of el.classList) {
      if (clz.startsWith('code-annotation-')) {                     
        return true;
      }
    }
    return false;
  }
  const clipboard = new window.ClipboardJS('.code-copy-button', {
    text: function(trigger) {
      const codeEl = trigger.previousElementSibling.cloneNode(true);
      for (const childEl of codeEl.children) {
        if (isCodeAnnotation(childEl)) {
          childEl.remove();
        }
      }
      return codeEl.innerText;
    }
  });
  clipboard.on('success', function(e) {
    // button target
    const button = e.trigger;
    // don't keep focus
    button.blur();
    // flash "checked"
    button.classList.add('code-copy-button-checked');
    var currentTitle = button.getAttribute("title");
    button.setAttribute("title", "Copied!");
    let tooltip;
    if (window.bootstrap) {
      button.setAttribute("data-bs-toggle", "tooltip");
      button.setAttribute("data-bs-placement", "left");
      button.setAttribute("data-bs-title", "Copied!");
      tooltip = new bootstrap.Tooltip(button, 
        { trigger: "manual", 
          customClass: "code-copy-button-tooltip",
          offset: [0, -8]});
      tooltip.show();    
    }
    setTimeout(function() {
      if (tooltip) {
        tooltip.hide();
        button.removeAttribute("data-bs-title");
        button.removeAttribute("data-bs-toggle");
        button.removeAttribute("data-bs-placement");
      }
      button.setAttribute("title", currentTitle);
      button.classList.remove('code-copy-button-checked');
    }, 1000);
    // clear code selection
    e.clearSelection();
  });
  function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
    const config = {
      allowHTML: true,
      maxWidth: 500,
      delay: 100,
      arrow: false,
      appendTo: function(el) {
          return el.parentElement;
      },
      interactive: true,
      interactiveBorder: 10,
      theme: 'quarto',
      placement: 'bottom-start',
    };
    if (contentFn) {
      config.content = contentFn;
    }
    if (onTriggerFn) {
      config.onTrigger = onTriggerFn;
    }
    if (onUntriggerFn) {
      config.onUntrigger = onUntriggerFn;
    }
    window.tippy(el, config); 
  }
  const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
  for (var i=0; i<noterefs.length; i++) {
    const ref = noterefs[i];
    tippyHover(ref, function() {
      // use id or data attribute instead here
      let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
      try { href = new URL(href).hash; } catch {}
      const id = href.replace(/^#\/?/, "");
      const note = window.document.getElementById(id);
      return note.innerHTML;
    });
  }
  const xrefs = window.document.querySelectorAll('a.quarto-xref');
  const processXRef = (id, note) => {
    // Strip column container classes
    const stripColumnClz = (el) => {
      el.classList.remove("page-full", "page-columns");
      if (el.children) {
        for (const child of el.children) {
          stripColumnClz(child);
        }
      }
    }
    stripColumnClz(note)
    if (id === null || id.startsWith('sec-')) {
      // Special case sections, only their first couple elements
      const container = document.createElement("div");
      if (note.children && note.children.length > 2) {
        container.appendChild(note.children[0].cloneNode(true));
        for (let i = 1; i < note.children.length; i++) {
          const child = note.children[i];
          if (child.tagName === "P" && child.innerText === "") {
            continue;
          } else {
            container.appendChild(child.cloneNode(true));
            break;
          }
        }
        if (window.Quarto?.typesetMath) {
          window.Quarto.typesetMath(container);
        }
        return container.innerHTML
      } else {
        if (window.Quarto?.typesetMath) {
          window.Quarto.typesetMath(note);
        }
        return note.innerHTML;
      }
    } else {
      // Remove any anchor links if they are present
      const anchorLink = note.querySelector('a.anchorjs-link');
      if (anchorLink) {
        anchorLink.remove();
      }
      if (window.Quarto?.typesetMath) {
        window.Quarto.typesetMath(note);
      }
      // TODO in 1.5, we should make sure this works without a callout special case
      if (note.classList.contains("callout")) {
        return note.outerHTML;
      } else {
        return note.innerHTML;
      }
    }
  }
  for (var i=0; i<xrefs.length; i++) {
    const xref = xrefs[i];
    tippyHover(xref, undefined, function(instance) {
      instance.disable();
      let url = xref.getAttribute('href');
      let hash = undefined; 
      if (url.startsWith('#')) {
        hash = url;
      } else {
        try { hash = new URL(url).hash; } catch {}
      }
      if (hash) {
        const id = hash.replace(/^#\/?/, "");
        const note = window.document.getElementById(id);
        if (note !== null) {
          try {
            const html = processXRef(id, note.cloneNode(true));
            instance.setContent(html);
          } finally {
            instance.enable();
            instance.show();
          }
        } else {
          // See if we can fetch this
          fetch(url.split('#')[0])
          .then(res => res.text())
          .then(html => {
            const parser = new DOMParser();
            const htmlDoc = parser.parseFromString(html, "text/html");
            const note = htmlDoc.getElementById(id);
            if (note !== null) {
              const html = processXRef(id, note);
              instance.setContent(html);
            } 
          }).finally(() => {
            instance.enable();
            instance.show();
          });
        }
      } else {
        // See if we can fetch a full url (with no hash to target)
        // This is a special case and we should probably do some content thinning / targeting
        fetch(url)
        .then(res => res.text())
        .then(html => {
          const parser = new DOMParser();
          const htmlDoc = parser.parseFromString(html, "text/html");
          const note = htmlDoc.querySelector('main.content');
          if (note !== null) {
            // This should only happen for chapter cross references
            // (since there is no id in the URL)
            // remove the first header
            if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
              note.children[0].remove();
            }
            const html = processXRef(null, note);
            instance.setContent(html);
          } 
        }).finally(() => {
          instance.enable();
          instance.show();
        });
      }
    }, function(instance) {
    });
  }
      let selectedAnnoteEl;
      const selectorForAnnotation = ( cell, annotation) => {
        let cellAttr = 'data-code-cell="' + cell + '"';
        let lineAttr = 'data-code-annotation="' +  annotation + '"';
        const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
        return selector;
      }
      const selectCodeLines = (annoteEl) => {
        const doc = window.document;
        const targetCell = annoteEl.getAttribute("data-target-cell");
        const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
        const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
        const lines = annoteSpan.getAttribute("data-code-lines").split(",");
        const lineIds = lines.map((line) => {
          return targetCell + "-" + line;
        })
        let top = null;
        let height = null;
        let parent = null;
        if (lineIds.length > 0) {
            //compute the position of the single el (top and bottom and make a div)
            const el = window.document.getElementById(lineIds[0]);
            top = el.offsetTop;
            height = el.offsetHeight;
            parent = el.parentElement.parentElement;
          if (lineIds.length > 1) {
            const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
            const bottom = lastEl.offsetTop + lastEl.offsetHeight;
            height = bottom - top;
          }
          if (top !== null && height !== null && parent !== null) {
            // cook up a div (if necessary) and position it 
            let div = window.document.getElementById("code-annotation-line-highlight");
            if (div === null) {
              div = window.document.createElement("div");
              div.setAttribute("id", "code-annotation-line-highlight");
              div.style.position = 'absolute';
              parent.appendChild(div);
            }
            div.style.top = top - 2 + "px";
            div.style.height = height + 4 + "px";
            div.style.left = 0;
            let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
            if (gutterDiv === null) {
              gutterDiv = window.document.createElement("div");
              gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
              gutterDiv.style.position = 'absolute';
              const codeCell = window.document.getElementById(targetCell);
              const gutter = codeCell.querySelector('.code-annotation-gutter');
              gutter.appendChild(gutterDiv);
            }
            gutterDiv.style.top = top - 2 + "px";
            gutterDiv.style.height = height + 4 + "px";
          }
          selectedAnnoteEl = annoteEl;
        }
      };
      const unselectCodeLines = () => {
        const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
        elementsIds.forEach((elId) => {
          const div = window.document.getElementById(elId);
          if (div) {
            div.remove();
          }
        });
        selectedAnnoteEl = undefined;
      };
        // Handle positioning of the toggle
    window.addEventListener(
      "resize",
      throttle(() => {
        elRect = undefined;
        if (selectedAnnoteEl) {
          selectCodeLines(selectedAnnoteEl);
        }
      }, 10)
    );
    function throttle(fn, ms) {
    let throttle = false;
    let timer;
      return (...args) => {
        if(!throttle) { // first call gets through
            fn.apply(this, args);
            throttle = true;
        } else { // all the others get throttled
            if(timer) clearTimeout(timer); // cancel #2
            timer = setTimeout(() => {
              fn.apply(this, args);
              timer = throttle = false;
            }, ms);
        }
      };
    }
      // Attach click handler to the DT
      const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
      for (const annoteDlNode of annoteDls) {
        annoteDlNode.addEventListener('click', (event) => {
          const clickedEl = event.target;
          if (clickedEl !== selectedAnnoteEl) {
            unselectCodeLines();
            const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
            if (activeEl) {
              activeEl.classList.remove('code-annotation-active');
            }
            selectCodeLines(clickedEl);
            clickedEl.classList.add('code-annotation-active');
          } else {
            // Unselect the line
            unselectCodeLines();
            clickedEl.classList.remove('code-annotation-active');
          }
        });
      }
  const findCites = (el) => {
    const parentEl = el.parentElement;
    if (parentEl) {
      const cites = parentEl.dataset.cites;
      if (cites) {
        return {
          el,
          cites: cites.split(' ')
        };
      } else {
        return findCites(el.parentElement)
      }
    } else {
      return undefined;
    }
  };
  var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
  for (var i=0; i<bibliorefs.length; i++) {
    const ref = bibliorefs[i];
    const citeInfo = findCites(ref);
    if (citeInfo) {
      tippyHover(citeInfo.el, function() {
        var popup = window.document.createElement('div');
        citeInfo.cites.forEach(function(cite) {
          var citeDiv = window.document.createElement('div');
          citeDiv.classList.add('hanging-indent');
          citeDiv.classList.add('csl-entry');
          var biblioDiv = window.document.getElementById('ref-' + cite);
          if (biblioDiv) {
            citeDiv.innerHTML = biblioDiv.innerHTML;
          }
          popup.appendChild(citeDiv);
        });
        return popup.innerHTML;
      });
    }
  }
});
</script>
<nav class="page-navigation">
  <div class="nav-page nav-page-previous">
      <a href="./calculus.html" class="pagination-link" aria-label="Calculus">
        <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text">Calculus</span>
      </a>          
  </div>
  <div class="nav-page nav-page-next">
      <a href="./optimization.html" class="pagination-link" aria-label="Optimization">
        <span class="nav-page-text">Optimization</span> <i class="bi bi-arrow-right-short"></i>
      </a>
  </div>
</nav>
</div> <!-- /content -->




</body></html>